package com.ezbuy.common.bean;

import java.util.ArrayList;
import java.util.List;

/**
 * ezbuy 2018/12/1 下午3:40
 */
public class MessageType {

    private ProtoFile file;
    public String name;
    public List<FieldType> fields = new ArrayList<>();
    public List<String> imports = new ArrayList<>();
    public List<MessageType> nestedTypes = new ArrayList<>();

    public ProtoFile getFile() {
        return file;
    }

    public void setFile(ProtoFile file) {
        this.file = file;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public List<FieldType> getFields() {
        return fields;
    }

    public void setFields(List<FieldType> fields) {
        this.fields = fields;
    }

    public List<String> getImports() {
        return imports;
    }

    public void setImports(List<String> imports) {
        this.imports = imports;
    }

    public void addImport(String imp) {
        if (imports.contains(imp)) {
            return;
        }
        this.imports.add(imp);
    }

    public List<MessageType> getNestedTypes() {
        return nestedTypes;
    }

    public void setNestedTypes(List<MessageType> nestedTypes) {
        this.nestedTypes = nestedTypes;
    }

    public void addNestedType(MessageType child) {
        this.nestedTypes.add(child);
    }

    @Override
    public String toString() {
        return "MessageType{" +
                "name='" + name + '\'' +
                ", fields=" + fields +
                ", imports=" + imports +
                ", nestedTypes=" + nestedTypes +
                '}';
    }
}
